# -*- coding: utf-8 -*-
'''
@文件    :myself.py
@说明    :
@时间    :2025/08/08 02:07:08
@作者    :浪晋
@版本    :1.0
'''
from fastapi import APIRouter
from app.core.routeclass import OperationLogRoute
from app.core.dependencies import DeepValidationAdminToken
from app.core.response import Success, Fail
from app.services.system.user import service as user_service
from app.services.system.menu import service as menu_service
from app.core.plugin import ctx


router = APIRouter(route_class=OperationLogRoute, dependencies=[DeepValidationAdminToken])


@router.get("/info",summary="获取用户资料")
async def myself_info():
    g = ctx.get("g")
    result = await user_service.get_by_id(g.id)
    return Success(data=result)


@router.get("/menus",summary="获取用户资料")
async def myself_menus():
    g = ctx.get("g")
    if g.superuser:
        result = await menu_service.get_superuser_menus()
    else:
        result = await user_service.get_user_menus(g.id)
    return Success(data=result)